<template>
    <div>
      <robot v-if="robotFlag"></robot>
      <el-container>
        <el-aside width="50%">
          <h1 class="homeTitle">smallFrog 书店</h1>
          <p class="content">我希望政通人和，使大家能安安静静坐下来，想一点事，读一点书，写一点文章。</p>
          <el-button class="startBtn" @click="robotB">书城机器人</el-button>
        </el-aside>
        <el-main>
          <div class="recommend">
            <h1 class="recommendTitle">为您推荐</h1>
            <div style="width: 600px; margin:auto">
              <el-carousel :interval="4000" type="card" height="400px">
                <el-carousel-item v-for="item in recBooks" :key="item[3]">
                  <router-link to="/about">
                    <img class="imglb" :src="item[2]"/>
                  </router-link>
                </el-carousel-item>
              </el-carousel>
            </div>
          </div>
        </el-main>
      </el-container>

    </div>
</template>

<script>
import robot from "@/views/robot";
export default {
  components:{
    robot
  },
  data() {
    return {
      recBooks: [
        [
          "79bbe618-d2f8-4081-b35a-62ebbe938b64",
          "Java基础入门",
          "/productImg/9/0/697a23d6-225a-41a3-8c20-7ab624265ecc.png",
          3
        ],
        [
          "3a0196b2-71c1-4d4d-a4e8-d1f875096f00",
          "网管员必备宝典",
          "/productImg/4/3/0270eba2-2b48-48df-956b-0341204384d9.jpg",
          2
        ],
        [
          "3cdd01d2-95d4-4077-b512-ff4c3b340d6b",
          "学会宽容",
          "/productImg/6/5/a2da626c-c72d-4972-83de-cf48405c5563.jpg",
          1
        ]
      ],
      transRecBooks: [],
      robotFlag:false
    }
  },
  created() {
  },
  methods: {
    robotB(){
      this.robotFlag=!this.robotFlag
    },
    transRec() {
      var Arr = [];
      for (var i = 0, idx = -1; i < this.recBooks.length; i++) {
        i % 4 == 0 && idx++;
        if (Object.prototype.toString.call(Arr[idx]) != "[object Array]")
          Arr[idx] = [];
        Arr[idx].push(this.recBooks[i]);
      }
      this.transRecBooks = Arr;
    },
    toInfo(e) {
      this.$router.push({
        path: "/bookInfo",
        query: {
          ID: e.ID
        }
      });
    }
  }
}
</script>

<style>
.imglb{
  width: 300px;
  height: 400px;
}
.homeTitle {
  width: 400px;
  color: #333333;
  font-size: 40px;
  font-weight: 600;
  text-align: left;
  margin-left: 150px;
}

.indexImg {
  width: 500px;
  margin: 0 auto;
}

.content {
  width: 400px;
  color: #333333;
  font-size: 18px;
  line-height: 35px;
  text-align: left;
  margin-left: 150px;
}

.startBtn {
  width: 150px;
  height: 40px;
  position: relative;
  left: 150px;
  top: 100px;
  border-radius: 25px;
  border: none;
  outline: none;
  background-color: #4F6E9D;
  color: #FFFFFF;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
}

.startBtn:focus,
.startBtn:hover {
  color: #FFFFFF;
  border-color: #7E9DCA;
  background-color: #7E9DCA;
}

.startBtn:active {
  color: #FFFFFF;
  border-color: #7E9DCA;
  outline: 0;
}

.recommend {
  margin-top: 30px;
  padding-top: 30px;
  padding-bottom: 50px;
}

.recommend .recommendTitle {
  color: #333333;
  text-align: center;
  font-size: 30px;
  font-weight: 600;
  margin-bottom: 50px;
}

.recommend .recLine {
  justify-content: center;
  display: flex;
}

.recommend .recLine .card {
  width: 200px;
  margin-top: 20px;
  margin-bottom: 20px;
  margin-left: 40px;
  margin-right: 40px;
  position: relative;
}

.recommend .recLine .card .img {
  width: 80%;
  height: 80%;
  display: block;
  cursor: pointer;
  margin: 0 auto;
  padding-top: 20px;
}

.recommend .recLine .card .name {
  padding-top: 14px;
  padding-left: 20px;
  padding-right: 20px;
  padding-bottom: 14px;
  font-size: 16px;
}

.recommend .recLine .card .rate {
  text-align: center;
  padding: 0 10px 14px 10px;
}

.el-link.el-link--default {
  color: #4f6e9d;
}

.el-link.el-link--default:hover {
  color: #7e9dca;
}

.recommend .recLine .row .readIcon {
  text-align: left;
  padding-right: 5px;
}

.recommend .recLine .row .rate {
  text-align: center;
  padding: 10px 10px 14px 10px;
}
</style>